// ① 引入
import Vue from 'vue'
import VueRouter from 'vue-router'
import HomePage from '@/views/HomePage.vue'
import News from '@/views/News.vue'
import Sport from '@/views/Sport.vue'
import HpSport from '@/views/HpSport.vue'
import InSport from '@/views/InSport.vue'
import OutSport from '@/views/OutSport.vue'

// ② 调用 Vue.use() 去注册这个插件
Vue.use(VueRouter)

// ③ 创建路由实例
const router = new VueRouter({
  routes: [
    {
      path: '/',
      redirect: '/homepage',
    },
    {
      path: '/homepage',
      component: HomePage,
    },
    {
      path: '/news',
      component: News,
    },
    {
      path: '/sport',
      component: Sport,
      children: [
        {
          path: 'hpsport',
          component: HpSport,
        },
        {
          path: 'insport',
          component: InSport,
        },
        {
          path: 'outsport',
          component: OutSport,
        },
      ],
    },
  ],
})
// 对外暴露
export default router
